import Vue from 'vue'
import VueRouter from 'vue-router'// 引入vue-router

Vue.use(VueRouter)// 加载全局组件Router

// 第三步:配置路由实例
const routes = [
  {
    path: '/',
    // 重定向到/home页面
    // redirect: '/home',
    component: () => import('@/views/layout/index.vue'),
    children: [
      {
        // 默认子路由
        path: '',
        component: () => import('@/views/home/index.vue')
      },
      {
        path: '/video',
        component: () => import('@/views/video/index.vue')
      },
      {
        path: '/qa',
        component: () => import('@/views/qa/index.vue')
      },
      {
        path: '/profile',
        component: () => import('@/views/profile/index.vue')
      }
    ]

  },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/search',
    // 路由懒加载
    component: () => import('@/views/search/index.vue')
  },
  {
    path: '/article/:articleId',
    props: true, // 代表开启props获取参数
    component: () => import('@/views/article/index.vue')
  }
]
// 创建 router 实例
const router = new VueRouter({
  routes
})

export default router
